a = input("Введите скобочную последовательность: ")
s = []
h = 0
f = 0
g = 0
for i in a:
    if i == "(":
        s.append(i)
        g = 1
    elif i == ")":
        h = s.pop(-1)
        if h != "(":
            f = 1
            break
    elif i == "{":
        s.append(i)
        g = 1
    elif i == "}":
        h = s.pop(-1)
        if h != "{":
            f = 1
            break
    elif i == "<":
        s.append(i)
        g = 1
    elif i == ">":
        if h != "<":
            f = 1
            break
        h = s.pop(-1)
    elif i == "[":
        s.append(i)
        g = 1
    elif i == "]":
        h = s.pop(-1)
        if h != "[":
            f = 1
            break
if f == 0 and g == 0:
    print("False")
elif len(s) == 0 and f == 0 and g == 1:
    print("True")
elif f > 0 or len(s) > 0:
    print("False")

